package com.jy.appmarket.network.resultdata;

import java.util.List;

import android.util.Log;

import com.jy.app.market.idata.Doc;
import com.jy.app.market.idata.card.Card;
import com.jy.app.market.idata.data.PageCard;

/**
 * 类说明：
 * 
 * @author kaixun.huang
 * @date 2014-5-7
 * @version 1.0
 */

public class PageResult extends BaseResultData {

	private static final String TAG = "PageResult";
	private List<Card> mCards;
	private long mDataVersion;
	private String mTitle;
	private int mPageNo;
	private int mTotalPage;

	public List<Card> getCards() {
		return mCards;
	}

	public long getDataVersion() {
		return mDataVersion;
	}

	public String getTitle() {
		return mTitle;
	}

	public int getPageNo() {
		return mPageNo;
	}

	public int getTotalPage() {
		return mTotalPage;
	}

	@Override
	public boolean parseResult(String result) {
		Doc doc = Doc.fromJson(result);
		if (doc == null) {
			return false;
		}
		setDataType(doc.getDataType());
		setStatus(doc.getStatus());
		setMessage(doc.getMessage());

		if (doc.isOk()) {
			if (doc.isType(PageCard.class)) {
				PageCard data = doc.getData();
				mCards = data.getCards();
				mDataVersion = data.getDataVersion();
				mTitle = data.getTitle();
				mPageNo = data.getPageNo();
				mTotalPage = data.getTotalPage();
				Log.d(TAG, "total page:" + data.getTotalPage());
				return true;
			}
		}
		return false;
	}

}
